if SERVER then
//AddCSLuaFile( "UpdateChecker.lua" )
local Updater = {}
Updater.errmsg = "The file you have specified doesn't exist. If the path you have entered is also wrong this may be due do the path also being wrong."
Updater.Path = "gamemodes/XXXX/" // this is the path of the file that has the revision number in it    NOT CAPS SENSITIVE
Updater.File = "revision.txt" // file name, this, however is caps sensitive
Updater.FileURL = "http://XXX.googlecode.com/svn/trunk/" // DO NOT INCLUDE THE FILE NAME but This needs to be the url on the svn you are updating from for the the file you are reading
Updater.FancyName = "" //this is the display name for whatever you are update checking. E.G "WireMod" , "Luapad" , ect


// helper function to find a file without case sensitivity
local function FindFile( str )
    local found
    strFile = str:gsub( "(%.%a+)" , string.lower)
    local explo = string.Explode( "/" , strFile )

    for level = 0 , #explo do
        local curlevel = explo[ level ]
        if level > 0 then
            found = file.Find( curlevel.."/*" , true)
        else
            found = file.Find( "*" , true )
        end
        for i = 1 , #found do
            local File = found[ i ]

            if string.lower(File) == string.lower(explo[ level + 1 ]) then
                explo[ level + 1 ] = File
            end
        end
    end
    return table.concat( explo , "/")
end

Updater.TruePath = FindFile( Updater.Path .. Updater.File )


if !file.Exists( Updater.TruePath , true) then MsgN( Updater.errmsg )
    return
end

Updater.CurrentRevision = tonumber(file.Read( Updater.TruePath ,true))
Updater.ShouldUpdate = false
Updater.LatestRevision = 0
local function httpCallBack(contents , size)
    Updater.LatestRevision = tonumber(contents)
    
    Updater.ShouldUpdate = Updater.LatestRevision > Updater.CurrentRevision
end
http.Get( Updater.FileURL .. Updater.File, "", httpCallBack) 


hook.Add("PlayerInitialSpawn","SVN_Update_Notification", function( ply )
    
    if Updater.ShouldUpdate then
        timer.Simple( 6 , function()
            if ply:IsSuperAdmin() then
                umsg.Start( "SVN_Update" , ply )
                    umsg.Short( Updater.CurrentRevision )
                    umsg.Short( Updater.LatestRevision )
                    umsg.String( Updater.FancyName )
                umsg.End()
            end
        end)
    end
end)
else

local function GetSVNRevisions( um )
    local CurrentRevision = tostring( um:ReadShort() )
    local LatestRevision = tostring( um:ReadShort() )
    local name = um:ReadString()
    chat.AddText( Color( 200 , 50 , 50) , "Update the server's ".. name .. " SVN... The latest revision is... " , Color(50 , 200 , 50) , CurrentRevision , Color( 200 , 50 , 50 )," and the latest revision is... " , Color( 50 , 200 , 50) , LatestRevision)
    chat.PlaySound()
end

usermessage.Hook( "SVN_Update" , GetSVNRevisions )

end